<?php
$aPath = Yii::app()->theme->baseUrl . '/assets/';
?>

<?php
foreach (Yii::app()->params['categories'] as $cat) {
	if (!empty($cat['faqUrl'])) {
		$arr1[] = $cat['faqUrl'];
		$arr2[] = $cat['pageUrl'];
	}
}
?>
<?php if ($type == 'cadtegory'): ?>
	<div class="slider-models-wrap">
		<div class="slider-models-wrap__inner">
			<dl class="widget">
				<!--<dt>Ремонт других телефонов</dt>-->
				<dd>
					<div class="owl-carousel slider-models">
	<?php
	foreach (Yii::app()->params['categories'] as $cat) {
		if (!empty($cat['faqUrl'])) {
			$arr1[] = $cat['faqUrl'];
			$arr2[] = $cat['pageUrl'];
		}
	}
	foreach ($models as $model) {
		if ($model['pageUrl'] != 'remont-kompyuterov') {
			$url = str_replace($arr2, $arr1, $model['pageUrl']);
                        $src = $this->getController()->getImageUrl('/image/resize/200x200/uploads/images/' . $model['pageType'] . '/' . $model['pageImages']);
			echo '<div class="item">
									<div class="slider-models__photo">
										<a class="image_link" href="/qa/' . $url . '">
											<img src="' . $src . '" alt="' . $model['pageTitle'] . '" />
										</a>
									</div>	
									<span>
										<a class="title_link" href="/qa/' . $url . '"><strong>' . $model['pageTitle'] . '</strong></a>
									</span>
								</div>';
		}
	}
	?>
					</div>
				</dd>
			</dl>
		</div>
	</div>    
<?php endif; ?>

<?php if ($type == 'brand' || $type == 'category'): ?>
	<h2 class="middle-title">Выберите производителя</h2>  
	<div class="brand-list">
		<ul>
	<?php
	foreach ($models as $model):
		$url = '/qa/' . str_replace($arr2, $arr1, $model['pageUrl']);
        $src = $this->getController()->getImageUrl('/image/resize/164x96/uploads/images/' . $type . '/' . $model['pageImages']);
		?>
				<li>
					<div class="brand-list__item">
						<div class="brand-list__photo">
				<?php echo CHtml::link('<img src="' . $src . '" alt="' . $model['pageTitle'] . '">', $url); ?>
						</div>
						<span>
							<?php echo CHtml::link($model['pageTitle'], $url); ?>
						</span>
					</div>    
				</li>
						<?php endforeach; ?>
		</ul>
	</div>
		<?php endif; ?>

<?php if ($type == 'model'): ?>
	<div class="model-selection">
		<dl>
			<dt>Укажите вашу модель</dt>
			<dd>
				<div class="wrap-bg">
					<noindex>
						<div class="type-text">
	<?php
	$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
		'name' => 'city',
		'source' => $searches,
		// additional javascript options for the autocomplete plugin
		'options' => array(
			'minLength' => '1',
			'showAnim' => 'fold',
			'select' => 'js: function(event, ui) 
							{
								window.location.href = "/" + ui.item.url;
								return false;
							}',
		),
		'htmlOptions' => array(
			'placeholder' => 'Название модели',
		),
	));
	?>
							<!--<input type="text" placeholder="Название модели" />-->
						</div>
					</noindex>
				</div>     
			</dd>
		</dl>
		<p>Например: <a href="<?php echo $random['url']; ?>"><?php echo $random['title']; ?></a></p>
	</div> 
	<div class="model-list stretched">
		<ul>
	<?php
	foreach ($datas as $data):
		$url = '/qa/' . str_replace($arr2, $arr1, $data['pageUrl']);
		?>
				<li>
					<div class="model-list__item">
						<div class="model-list__photo">
		<?php
                $src = $this->getController()->getImageUrl('/image/resize/200x200/uploads/images/model/' . $data['pageImages']);
		echo CHtml::link('<img src="' . $src . '" alt="' . $data['pageTitle'] . '">', $url);
		?>			
						</div>
						<span>
							<?php echo CHtml::link(' ' . $data['pageTitle'], $url); ?>						
						</span>
					</div>    
				</li>
	<?php endforeach; ?>
		</ul>
	</div> 
	<nav class="page-navi">
	<?php
	$this->widget('CLinkPager', array(
		'pages' => $pages,
		'header' => '',
		'cssFile' => Yii::app()->theme->baseUrl . '/assets/css/pager.css',
		'firstPageLabel' => '&lt;&lt;',
		'prevPageLabel' => 'Предыдущая страница',
		'nextPageLabel' => 'Следующая страница',
		'lastPageLabel' => '&gt;&gt;',
	));
	?>	
	</nav>
	<style>
		.ui-autocomplete {
			max-height: 200px;
			overflow-y: auto;
			/* prevent horizontal scrollbar */
			overflow-x: hidden;
			/* add padding to account for vertical scrollbar */
			padding-right: 20px;
		}
		/* IE 6 doesn't support max-height
		 * we use height instead, but this forces the menu to always be this tall
		 */
		* html .ui-autocomplete {
			height: 100px;
		}
	</style>


<?php endif; ?>
